<template>
  <div class="base-setting">
    <div class="setting-panel">
      <div class="panel-header">
        <p class="panel-title">基本信息</p>
      </div>
      <el-card>
        <el-form
          ref="task"
          :model="workflow"
          label-width="120px"
          size="mini"
          label-position="right"
        >
          <el-form-item label="工作流名称">
            <span>{{ workflow.name }}</span>
          </el-form-item>
          <el-form-item label="通知到个人邮箱">
            <el-checkbox v-model="workflow.email_alert"></el-checkbox>
          </el-form-item>
          <el-form-item
            label="邮箱"
            prop="email"
            :rules="[ { type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur' }]"
          >
            <el-input v-model="workflow.email" ></el-input>
          </el-form-item>
          <!-- <el-form-item label="工作流名称">
            <span>{{ workflow.name }}</span>
          </el-form-item> -->
          <el-form-item label="工作流描述">
            <el-input v-model="workflow.description" :rows="6" type="textarea"></el-input>
          </el-form-item>
        </el-form>
      </el-card>
    </div>
  </div>
</template>
<script>
export default {
  name: "WorkflowSettingBase",
  props: {
    id: String
  },
  data() {
    return {
      workflow: {
        name: "",
        description: "",
        email: ""
      }
    };
  },

  created() {
    this.initData();
  },
  methods: {
    initData() {
      this.$http.workflow.getWorkflowById({ id: this.id }).then(res => {
        this.workflow = res;
      });
    },
    // 设置保存
    save(nodes) {
      if (!this.workflow.id) return;
      this.$http.workflow
        .updateWorkflow({
          id: this.workflow.id,
          description: this.workflow.description,
          email: this.workflow.email,
          content: { nodes }
        })
        .then(res => {
          this.$message({
            type: "success",
            message: "保存成功"
          });
        });
    }
  }
};
</script>
<style lang="scss">
.base-setting {
  height: calc(100vh - 120px);
  overflow: auto;
}
</style>
